package utils;

import java.util.Collection;

public class ArgumentAssertion {

	/**
	 * Asserts that an argument is not null.
	 * 
	 * @param name
	 *            Name of argument.
	 * @param obj
	 *            Argument.
	 */
	public static void assertNotNull(String name, Object obj) {
		if (obj == null) {
			throw new IllegalArgumentException("Argument " + name
			        + " must not be null.");
		}
	}

	public static <T> void assertNotEmpty(String name, Collection<T> collection) {
		assertNotNull(name, collection);

		if (collection.isEmpty())
			throw new IllegalArgumentException("Argument " + name
			        + " must not be empty.");
	}

	public static void assertPositive(String name, long number) {
		if (number <= 0)
			throw new IllegalArgumentException("Argument " + name
			        + " must be positive.");
	}
}
